package products;

enum State {NEW,LOADED,CHANGED};

public class Product {
	private String name;
	private String description;
	private double cost;
	private State state = State.NEW;
	
	//Constructorul clasei Product
	public Product(String name, String description, double cost){
		this.name = name;
		this.description = description;
		this.cost = cost;
	}
	
	public String getName() {
		return name;
	}
	
	public String getDescription() {
		return description;
	}
	
	public double getCost() {
		return cost;
	}
	
	public void setName(String name) {
		this.state = State.CHANGED;
		this.name = name;
	}
	
	public void setDescription(String description) {
		this.state = State.CHANGED;
		this.description = description;
	}
	
	public void setCost(double cost) {
		this.state = State.CHANGED;
		this.cost = cost;
	}
	
	public String toString() {
		return "Name: "+name+"\n"+"Description: "+description+"\n"+"Cost: "+cost+"\n"+"State: "+state;
	}
	
	//Pastreaza o copie a obiectului de tip Product
	public ProductMemento memento() {
		return new ProductMemento(name, description, cost, state);
	}
	
	//Realizarea restaurarii obiectului curent
	public void restoreMemento(ProductMemento memento) {
		this.name = memento.getName();
		this.description = memento.getDescription();
		this.cost = memento.getCost();
		this.state = memento.getState();
	}
}
